#light
// These references are required only for typechecking purposes
// you can skip their evaluation.
#r "ViewletControls.dll"
#r "VSLabFSICore.dll"
#r "Microsoft.DirectX.Direct3D"
#r "VSLabChart3DPackage.dll"
#r "VSLabChartPackage.dll"

open System.Drawing
open VSLab.Chart3D
open VSLab.Chart
open LightweightControls

let viewer1 = new Function3DViewlet(Name = "first 3D function")
let mutable v = 0.1

let btn1 = LightweightButton(Position = Point(30,90), Text = "Button1")
btn1.Click.Add(fun _ -> viewer1.Function <- fun (t:float) (x, y) -> sin(t)*v*(x-y))

let btn2 = LightweightButton(Position = Point(130,90), Text = "Button2")
btn2.Click.Add(fun _ -> viewer1.Function <- fun (t:float) (x, y) -> sin(t+x+y) + x*y + y*x)

let btn3 = LightweightButton(Position = Point(230,90), Text = "Button3")
let flag = ref false
btn3.Click.Add(fun _ -> if !flag then v <- 0.5 else v <- 1.0; flag := not !flag)

viewer1.Add(btn1)
viewer1.Add(btn2)
viewer1.Add(btn3)

viewer1.Show()
viewer1.Close()

let gv = new GraphControl()
gv.Add(LightweightButton(Position = Point(130,90), Text = "Button2"))
gv.Show()
gv.SetViewletStyle(ControlStyles.DoubleBuffer, true)
gv.ShowProperty()
gv.Close()
